package com.sky.controller.admin;

import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.admin.DishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description DishController
 * @Author liujiangyuan
 * @Date 2024-10-11-20:31
 */
@RestController
@Slf4j
@Api(tags="菜品相关接口")
@RequestMapping("/admin/dish")
public class DishController {
    @Autowired
    private DishService dishService;

    @PostMapping
    @ApiOperation("添加菜品")
    public Result adddish(@RequestBody DishDTO dishDTO){
        log.info("添加菜品 参数：{}",dishDTO.toString());
        dishService.addDish(dishDTO);
        return Result.success();
    }
    @GetMapping("/page")
    @ApiOperation("分页查询")
    public Result<PageResult> querypage(DishPageQueryDTO dishPageQueryDTO){
        log.info( " 分页查询 参数：{}",dishPageQueryDTO.toString());

        return Result.success(dishService.queryPage(dishPageQueryDTO));
    }
    @DeleteMapping
    @ApiOperation("删除菜品")
    public Result deletedish(@RequestParam("ids") List<Integer> ids){
        log.info("删除菜品 参数：{}",ids.toString());
        dishService.deleteDish(ids);
        return Result.success();
    }

}
